<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>OpenLayers Test</title>
    <link rel="stylesheet" href="../libs/OpenLayers/ol.css" type="text/css">

    <script type="text/javascript">
        htconfig = {
            Default: {
                paletteTitleBackground: 'rgb(240,239,238)',
                paletteTitleHoverBackground: 'rgb(231,231,231)',
                paletteTitleLabelColor: 'rgb(138, 138, 138)',
                paletteItemSelectBackground: '',
                paletteItemHoverBorderColor: 'rgb(138, 138, 138)',

                toolTipBackground: 'rgb(255, 255, 255)',

                dialogButtonBackground: 'rgb(231, 76, 60)',
                dialogButtonSelectBackground: 'rgb(196, 65, 51)',
                dialogButtonLabelColor: '#fff',

                buttonBackground: '',
                buttonSelectBackground: 'rgb(231, 231, 231)',
                buttonLabelColor: 'rgb(159, 159, 159)',
                comboBoxLabelColor: 'rgb(159, 159, 159)',
                comboBoxSelectBackground: 'rgb(138, 138, 138)'
            },
            Color: {
                titleBackground: '#076186',// 指定HT所有组件的标题栏的背景色，如面板，对话框，AccordionView等
                titleIconBackground: 'rgb(186, 186, 186)',// 指定HT所有组件的标题ICON的颜色，如面板，对话框，AccordionView等
                headerBackground: '#DAECF4'// 指定HT所有组件的header背景色，如表格表头、工具条等
            }
        };
    </script>
    <script src='../libs/core/IZrowIfUVaXF.js'></script>
    <script src='../libs/core/VT3MIEkV8AKv.js'></script>
    <script src='../libs/core/ht.js'></script>
    <script src='../libs/core/buckle.js'></script>
    <script src='../libs/core/ht-ui.js'></script>
    <script src='../libs/plugin/ht-edgetype.js'></script>
    <script src="../libs/plugin/ht-obj.js"></script>
    <script src='../libs/plugin/ht-form.js'></script>
    <script src='../libs/plugin/ht-vector.js'></script>
    <script src='../libs/plugin/ht-animation.js'></script>
    <script src='../configs/htconfig.js'></script>
    <script src="../libs/echarts.min.js"></script>
    <script src='../libs/echarts.js'></script>
    <script src='../libs/jquery-3.4.1.min.js'></script>
    <script src='../libs/echarts.js'></script>
    <script src='../libs/buckle.js'></script>
    <script src='../libs/knU3sXefAa5Q.js'></script>
    <script src="../configs/urlConfig.js"></script>


    <!-- <script src="libs/ht-palette.js"></script> -->
    <!--    <script src="../libs/OpenLayers/ol-debug.js"></script>-->
    <script src="../libs/OpenLayers/ol.js"></script>
    <!-- <script src="custom/libs/OpenLayers/CreateEdgeInteractor.js"></script>
    <script src="custom/libs/OpenLayers/CreateShapeInteractor.js"></script> -->
    <script src="../libs/OpenLayers/GraphViewControl.js"></script>

    <style type="text/css">
        html,
        body {
            margin: 0;
            padding: 0;
        }
    </style>

<script type="text/javascript">
    var dataModel = new ht.DataModel();
    var startId = 0;
    var showTableData = [];

    //地图定位
    const centermap = new Map();

    centermap.set("", ol.proj.transform([116.88, 40.72], 'EPSG:4326', 'EPSG:3857'));
    //centermap.set("",ol.proj.transform([119.045643, 40.72], 'EPSG:4326', 'EPSG:3857'));
    centermap.set(5, ol.proj.transform([114.504000, 40.851901], 'EPSG:4326', 'EPSG:3857'));
    centermap.set(6, ol.proj.transform([118.175393, 39.65113], 'EPSG:4326', 'EPSG:3857'));
    centermap.set(7, ol.proj.transform([116.704441, 39.523927], 'EPSG:4326', 'EPSG:3857'));
    centermap.set(8, ol.proj.transform([117.939152, 40.976204], 'EPSG:4326', 'EPSG:3857'));
    centermap.set(9, ol.proj.transform([119.586579, 39.942531], 'EPSG:4326', 'EPSG:3857'));
    //地区阴影
    const shadowlist = ["../libs/OpenLayers/zjk.json",
        "../libs/OpenLayers/ts.json",
        "../libs/OpenLayers/qhd.json",
        "../libs/OpenLayers/lf.json",
        "../libs/OpenLayers/cd.json"];

    graphViewControl = new GraphViewControl();// 自定义控件，作为 openlayers 地图上自定义控件
    graphView = graphViewControl.getGraphView();// 获取拓扑图组件
    graphView_global = graphView;

    // dm = graphView.getDataModel();// 获取拓扑图中的数据容器
    function init() {
        console.log('init--------------------');
        graphView.addToDOM();
        var mapDiv = document.getElementById('mapDiv');
        let maxExtent = ol.extent.boundingExtent([[119.045643, 42.397608], [114.514793, 38.042225]]);
        map = new ol.Map({
            target: 'mapDiv',// 地图容器
            controls: ol.control.defaults({
                zoom: false,
                rotate: false,
                attribution: false
            }).extend([
                graphViewControl,// 自定义拓扑控件
                new ol.control.ScaleLine(),// 比例尺控件
            ]),
            // 地图图层
            layers: [
                new ol.layer.Tile({
                    source: new ol.source.XYZ({
                        //瓦片的URL,由于只有冀北地图
                        url: 'http://24.43.105.10:18084/maps2/{z}/{y}/{x}.png'
                    })
                })
            ],
            // 地图视图
            view: new ol.View({
                center: centermap.get(""),// 视图的初始中心
                zoom: 8,// 缩放级别 用于计算视图的初始分辨率
                minZoom: 8,
                maxZoom: 11,
                extent: ol.proj.transformExtent(maxExtent, 'EPSG:4326', 'EPSG:3857')
            })
        });
        borderPane = new ht.widget.BorderPane();
        borderPane.setCenterView(mapDiv);
        borderPane.addToDOM();// 将面板组件添加到 body 中
        borderPane.addViewListener(function (e) {
            if (e.kind !== 'validate') return;// 刷新事件
            map.updateSize();// 用第三方插件的时候强制刷新地图
        });
        // 初始化地区阴影
        shadowlist.forEach(function (shadowpath) {
            let tmp = new ol.layer.Vector({ //初始化矢量图层
                source: new ol.source.Vector({
                    projection: 'EPSG:4326',
                    url: shadowpath,  //从文件加载边界等地理信息
                    format: new ol.format.GeoJSON()
                }),
                style: new ol.style.Style({
                    stroke: new ol.style.Stroke({
                        color: '#81aad8',
                        width: 2
                    }),
                    fill: new ol.style.Fill({
                        color: '#81aad866'
                    })
                })
            });
            map.addLayer(tmp);
        })

        map.on('postrender', function (e) {
        });
        // 监控缩放
        map.on("moveend", function (e) {
            //获取当前地图的缩放级别
            var zoom = map.getView().getZoom();
            let layers = graphView.getLayers();
            if (layers) {
                if (zoom >= 9) {
                    map.getLayers().forEach(function (item) {
                        if (item !== undefined && item.name !== undefined) {
                            item.setVisible(true);
                        }
                    });
                    layers[1].visible = false;
                    layers[2].visible = true;
                    dataModel.getDataByTag('rightblock').setLayer("2")
                    dataModel.getDataByTag('leftblock').setLayer("2")
                    dataModel.getDataByTag('rightblock').getChildren().forEach(function (data) {
                        data.setLayer("2")
                    });
                    dataModel.getDataByTag('leftblock').getChildren().forEach(function (data) {
                        data.setLayer("2")
                    });
                    dataModel.getDataByTag('图例').setLayer("2");
                    dataModel.getDataByTag('trianglebt').setLayer("2");
                } else {
                    map.getLayers().forEach(function (item) {
                        if (item !== undefined && item.name !== undefined) {
                            item.setVisible(false);
                        }
                    });
                    layers[1].visible = true;
                    layers[2].visible = false;
                    dataModel.getDataByTag('rightblock').setLayer("1")
                    dataModel.getDataByTag('leftblock').setLayer("1")
                    dataModel.getDataByTag('rightblock').getChildren().forEach(function (data) {
                        data.setLayer("1")
                    });
                    dataModel.getDataByTag('leftblock').getChildren().forEach(function (data) {
                        data.setLayer("1")
                    });
                    dataModel.getDataByTag('图例').setLayer("1");
                    dataModel.getDataByTag('trianglebt').setLayer("1");
                }
            }
        });
        graphView.deserialize('displays/冀北/区域总览.json', function (json, dm, gv, datas) {
            document.title = "区域总览";
            if (json.a['json.background']) {
                var bgJSON = json.a['json.background'];
                if (bgJSON.indexOf('displays') === 0) {
                    var bgGv = new ht.graph.GraphView();
                    bgGv.deserialize(bgJSON);
                    bgGv.addToDOM();
                    graphView.addToDOM(bgGv.getView());
                } else if (bgJSON.indexOf('scenes') === 0) {
                    var bgG3d = new ht.graph3d.Graph3dView();
                    bgG3d.deserialize(bgJSON);
                    bgG3d.addToDOM();
                    graphView.addToDOM(bgG3d.getView());
                }
                graphView.handleScroll = function () {
                };
            }

            dataModel = dm;
            //定位地区
            var zhangjiakou = dm.getDataByTag('zhangjiakou');
            var chengde = dm.getDataByTag('chengde');
            var tangshan = dm.getDataByTag('tangshan');
            var qinhuangdao = dm.getDataByTag('qinhuangdao');
            var langfang = dm.getDataByTag('langfang');

            zhangjiakou.a('coord', [114.30, 40.83]);
            chengde.a('coord', [117.400152, 40.976204]);
            tangshan.a('coord', [117.655393, 39.65113]);
            qinhuangdao.a('coord', [119.01, 40.10]);
            langfang.a('coord', [116.164441, 39.523927]);


            //初始化数据
            getAreaIdAndName();
            getWindFieldMap();
            dataModel.getDataByTag('comboBoxArea').a('ht.value', "");
            getStationIdAndNameInArea("");
            dataModel.getDataByTag('comboBoxTerminal').a('ht.value', "");


            var startDate = dataModel.getDataByTag('startDate').a('ht.value');
            var endDate = dataModel.getDataByTag('endDate').a('ht.value');
            var areaId = dataModel.getDataByTag('comboBoxArea').a('ht.value');
            var unitId = '';
            // 各时间选择器设置默认值
            // 获取当前时间时间戳（毫秒）
            var currentTime = Date.now();
            //将当前时间转换成时间格式
            var currentDate = new Date(parseInt(currentTime));
            var yy = currentDate.getFullYear();      //年
            var mm = currentDate.getMonth() + 1;     //月
            var dd = currentDate.getDate();          //日

            var endDate = yy + "-";
            if (mm < 10) endDate += "0";
            endDate += mm + "-";
            if (dd < 10) endDate += "0";
            endDate += dd;

            dataModel.getDataByTag('endDate').a('ht.value', endDate);

            //开始时间与结束时间相隔60天，转换成毫秒
            var offsetTime = 1000 * 3600 * 24 * 60;
            //将结束时间减去相隔时间即为开始时间
            var startTime = currentTime - offsetTime;
            startTime = new Date(parseInt(startTime));
            var yy = startTime.getFullYear();      //年
            var mm = startTime.getMonth() + 1;     //月
            var dd = startTime.getDate();          //日

            var startDate = yy + "-";
            if (mm < 10) startDate += "0";
            startDate += mm + "-";
            if (dd < 10) startDate += "0";
            startDate += dd;
            dataModel.getDataByTag('startDate').a('ht.value', startDate);
            getDefectWarn(areaId, "", unitId, startDate, endDate);//获取报警信息
            operateHoursAnalyse(areaId, "", unitId, startDate, endDate);//右侧两饼图数据
            areaOperateAnLossHours(startDate, endDate);

        });
    }

    //-------------------------------------------------------------------------------------------------------------------------

    //各区域悬浮
    function showPop(areaId, startTime, endTime) {
        let urlTime = attributeConfig.url + "/epplatform/operateHours/operateHoursAnalyse?" //故障停机时间分析

        if (areaId) {
            urlTime = urlTime + "areaId=" + areaId + "&";
        }
        if (startTime) {
            urlTime = urlTime + "startTime=" + startTime + "&";
        }
        if (endTime) {
            urlTime = urlTime + "endTime=" + endTime + "&";
        }
        //故障停机时间分析
        $.ajax({
            url: urlTime,
            type: "GET",
            contentType: "application/json",
            dataType: "json",
            data: JSON.stringify(),
            success: function (result) {
                if (result.data.length != 0) {
                    graphView_global.each(function (data) {
                        data._dataModel.getDataByTag('场站悬浮').a('data', result.data);
                    });
                }
            }
        });
    }

    //获取缺陷预警信息
    function getDefectWarn(areaId, stationId, plantUnit, startTime, endTime) {
        let param = {
            "areaId": areaId,
            "stationId": stationId,
            "unitId": plantUnit,
            "startTime": startTime,
            "endTime": endTime
        }
        $.ajax({
            url: attributeConfig.url + "/epplatform/v1/regionSituationTrack/defectWarn",
            type: "POST",
            contentType: "application/json",
            dataType: "json",
            data: JSON.stringify(param),
            success: function (result) {
                tabledata = result.data;
                //给表格数据添加上id
                tabledata1 = running(tabledata);
                if (tabledata1 && tabledata1.length != 0) {
                    //初始化表格
                    startId = changeData(tabledata1, startId, showTableData)
                    setInterval(function () {
                        startId = changeData(tabledata1, startId, showTableData)
                    }, 3 * 1000);
                    //dataModel.getDataByTag('暂无数据').s('2d.visible',false);
                } else {
                    var obj = {
                        "id": "0",
                        "context": "暂无报警记录"
                    }
                    tabledata1.push(obj);
                    startId = changeData(tabledata1, startId, showTableData)

                    //dataModel.getDataByTag('暂无数据').s('2d.visible',true);
                }
            }
        });
    }


    //获取故障停机时间分析及损失电量分析
    function operateHoursAnalyse(areaId, stationId, plantUnit, startTime, endTime) {
        let urlTime = attributeConfig.url + "/epplatform/operateHours/operateHoursAnalyse?" //故障停机时间分析

        if (areaId) {
            urlTime = urlTime + "areaId=" + areaId + "&";
        }
        if (stationId) {
            urlTime = urlTime + "stationId=" + stationId + "&";
        }
        if (plantUnit) {
            urlTime = urlTime + "plantUnit=" + plantUnit + "&";
        }
        if (startTime) {
            urlTime = urlTime + "startTime=" + startTime + "&";
        }
        if (endTime) {
            urlTime = urlTime + "endTime=" + endTime + "&";
        }
        //故障停机时间分析
        $.ajax({
            url: urlTime,
            type: "GET",
            contentType: "application/json",
            dataType: "json",
            data: JSON.stringify(),
            success: function (result) {
                if (result.data.length != 0) {
                    dataModel.getDataByTag('breakdown_downtime_analysis').a('pieData', result.data);
                }
            }
        });

        let param = {
            "areaCode": areaId,
            "stationId": stationId,
            "unitId": "",
            "startTime": startTime,
            "endTime": endTime
        }
        //损失电量分析
        $.ajax({
            url: attributeConfig.url + "/epplatform/v1/electricityAnalysis/unitLostElect",
            type: "POST",
            contentType: "application/json",
            dataType: "json",
            data: JSON.stringify(param),
            success: function (result) {
                if (result.data) {
                    if (result.data.length != 0) {
                        dataModel.getDataByTag('lost_electric_quantity_analysis ').a('data', result.data);
                    }
                }
            }
        });
    }

    //获取各区域运行小时数和损失小时数
    function areaOperateAnLossHours(startTime, endTime) {
        let urlOAL = attributeConfig.url + "/epplatform/areaStateTrack/areaStationOperateAnLossHours?"

        if (startTime) {
            urlOAL = urlOAL + "startTime=" + startTime + "&";
        }
        if (endTime) {
            urlOAL = urlOAL + "endTime=" + endTime + "&";
        }
        $.ajax({
            url: urlOAL,
            type: "GET",
            contentType: "application/json",
            dataType: "json",
            data: JSON.stringify(),
            success: function (result) {
                if (result.data) {
                    result.data.map(((item, index) => {
                        if (item.areaId === 5) {
                            //张家口
                            graphView_global.each(function (data) {
                                data._dataModel.getDataByTag('ZJK_渐变柱图').a('runningHours', item.runtime);
                                data._dataModel.getDataByTag('ZJK_渐变柱图').a('lostHours', item.losstime);
                            });
                        } else if (item.areaId === 6) {
                            //唐山
                            graphView_global.each(function (data) {
                                data._dataModel.getDataByTag('TS_渐变柱图').a('runningHours', item.runtime);
                                data._dataModel.getDataByTag('TS_渐变柱图').a('lostHours', item.losstime);
                            });
                        } else if (item.areaId === 7) {
                            //廊坊
                            graphView_global.each(function (data) {
                                data._dataModel.getDataByTag('LF_渐变柱图').a('runningHours', item.runtime);
                                data._dataModel.getDataByTag('LF_渐变柱图').a('lostHours', item.losstime);
                            });
                        } else if (item.areaId === 8) {
                            //承德
                            graphView_global.each(function (data) {
                                data._dataModel.getDataByTag('CD_渐变柱图').a('runningHours', item.runtime);
                                data._dataModel.getDataByTag('CD_渐变柱图').a('lostHours', item.losstime);
                            });
                        } else if (item.areaId === 9) {
                            //秦皇岛
                            graphView_global.each(function (data) {
                                data._dataModel.getDataByTag('QHD_渐变柱图').a('runningHours', item.runtime);
                                data._dataModel.getDataByTag('QHD_渐变柱图').a('lostHours', item.losstime);
                            });
                        }
                    }))
                }
            }
        });
    }

    function running(tabledata) {
        var tmp;
        if (tabledata) {
            for (var i = 0; i < tabledata.length; i++) {
                if (tabledata[i]) {
                    tmp = tabledata[i];

                    tmp['id'] = i;
                    tabledata[i] = tmp;
                }
            }
            return tabledata;
        }
    }

    //变换数据
    function changeData(tabledata, startId, showTableData) {
        showTableData = [];
        var flag = true;
        for (var i = 0; i < 4; i++) {
            if (tabledata[startId + i]) {
                showTableData[i] = tabledata[startId + i];
            } else {
                startId = 0;
                flag = false;
                break;
            }
        }
        //console.log('changeTableData===================',showTableData);
        var table = dataModel.getDataByTag('tt');
        if (showTableData.length > 0) {
            table.a({
                'ht.dataSource': showTableData
            });
        }
        if (flag) {
            startId = startId + 4;
        }
        return startId;

    }

    //获取区域名称和对应ID
    function getAreaIdAndName() {
        $.ajax({
            url: attributeConfig.url + "/epplatform/areaStateTrack/getAreaIdAndName",
            type: "GET",
            contentType: "application/json",
            dataType: "json",
            data: JSON.stringify(),
            success: function (result) {
                let array = [];
                result.data.map(((item, index) => {
                    array.push(Object.assign({}, {label: item.areaName, value: item.id}))
                }))
                dataModel.getDataByTag('comboBoxArea').a('ht.dataSource', array);
            }
        });
    }

    //获取区域下场站id和名称
    function getStationIdAndNameInArea(areaId) {
        $.ajax({
            url: attributeConfig.url + "/epplatform/areaStateTrack/getStationIdAndNameInArea" + "?areaId=" + areaId,
            type: "GET",
            contentType: "application/json",
            dataType: "json",
            data: JSON.stringify(),
            success: function (result) {
                if (result.data) {
                    let array = [];
                    result.data.map(((item, index) => {
                        array.push(Object.assign({}, {label: item.stationName, value: item.id}))
                    }))
                    dataModel.getDataByTag('comboBoxTerminal').a('ht.dataSource', array);
                }
            }
        });
    }

    //获取场站坐标
    function getWindFieldMap() {
        $.ajax({
            url: attributeConfig.url + "/epplatform/areaStateTrack/getAllStationPositionAndProperty",
            type: "GET",
            contentType: "application/json",
            dataType: "json",
            data: JSON.stringify(),
            success: function (result) {
                windFieldMap = result.data;
                //createIcon(windFieldMap);
                createNodes(dataModel, windFieldMap);//初始化场站位置
            }
        });
    }

    //创建风电场node
    function createNodes(dm, datas) {
        console.log("加载风电场");
        var host = dm.getDataByTag("zhangjiakou").getHost();
        for (var i = 0; i < datas.length; i++) {
            var node = new ht.Node();
            node.setLayer('2');
            node.setImage('symbols/冀北大数据/场站.json');
            node.setHost(host);
            node.s('2d.movable', false);
            var temp = datas[i];

            if (temp.name) {
                node.a('changzhan_name', temp.name);
                node.setName(temp.name);
                node.s('label.color', 'rgba(3,168,163,1)');//名称颜色
                node.s('label.font', '22px Microsoft YaHei');//名称字体
                node.s('label.offset.y', 0);//文字位置y轴偏移量
                node.s('label.background', 'rgba(255,255,255,0.8)');//文字背景颜色
            }
            if (temp.location) {
                //设置图元矩形区域
                // node.setRect(temp.position.x, temp.position.y, 60, 78);
                createIcon(temp)
                console.log("模拟数据风电场位置数据");
                node.a('coord', [temp.location.longitude, temp.location.latitude]);
                //node.setPosition(temp.position.x, temp.position.y);
                if (temp.id) {
                    node.setTag(temp.id);
                }
                // dm.add(node, 5);
            } else {
                node.s('2d.visible', false);
            }
        }

        //点击场站图标事件
        map.on('click', function (evt) {
            map.forEachFeatureAtPixel(evt.pixel, function (feature, layer) {
                var property = feature.getProperties();//获取feature中放置的数据
                if (property.id && property.name) {
                    cometo(property.id, property.name);
                }
            });
        });

        // 鼠标 场站悬浮窗
        map.on('pointermove', function (evt) {
            var detail = dataModel.getDataByTag('电场悬浮');
            var property;
            var mfeature = map.forEachFeatureAtPixel(evt.pixel, function (feature, layer) {
                if (feature.get('level') == 'city' || feature.get('level') == 'province' || feature.get("level") === undefined) {
                    detail.s('2d.visible', false);
                }
                property = feature.getProperties();
                return feature;
            });
            if (mfeature && mfeature.get('level') != 'city' && mfeature.get('level') != 'province') {
                var temp = property.data;
                let startTime = dataModel.getDataByTag('startDate').a('ht.value');
                let endTime = dataModel.getDataByTag('endDate').a('ht.value');
                detail.s('2d.visible', true);
                var coord = [temp.location.longitude, temp.location.latitude];
                var position = map.getPixelFromCoordinate(ol.proj.transform(coord, 'EPSG:4326', 'EPSG:3857'));
                detail.setPosition(position[0] - 280, position[1] - 100);
                detail.a('windFarmName', temp.name);
                if (temp.volume) {//装机容量
                    detail.a('installedCapacity', temp.volume);
                }
                if (temp.value) {//风机台数
                    detail.a('fanNum', temp.value + '台');
                }
                stationOperateAnLossHours(temp.id, startTime, endTime);//获取运行、损失小时数
            } else {
                detail.s('2d.visible', false);
                return;
            }
        });
    }

    //--------------显示区域定位标签------------
    function createIcon(datas) {
        var iconFeature = new ol.Feature({
            geometry: new ol.geom.Point(ol.proj.transform([datas.location.longitude, datas.location.latitude], 'EPSG:4326', 'EPSG:3857')),
            name: datas.name,
            id: datas.id,
            data: datas
        });
        iconFeature.setStyle(new ol.style.Style({
            image: new ol.style.Icon({
                anchor: [0.5, 60],              //锚点
                anchorXUnits: 'fraction',       //锚点X值单位
                anchorYUnits: 'pixels',         //锚点Y值单位
                anchorOrigin: 'top-right',    //锚点源
                offsetOrigin: 'top-right',   //偏移原点
                opacity: 1,                  //透明度
                scale: 0.5,                     //比例
                src: "symbols/冀北大数据/场站.png"
            }),
            text: new ol.style.Text({
                text: datas.name,
                font: '14px font-size', // 设置字体大小
                fill: new ol.style.Fill({// 设置字体颜色
                    color: '#03A8A3'
                }),
                backgroundFill: new ol.style.Fill({//标签的背景填充
                    color: '#F5FBFC',
                    width: 100
                }),
                offsetY: 20// 设置文字偏移量
            })
        }));

        let vectorSource = new ol.source.Vector({});

        vectorSource.addFeature(iconFeature);
        let vectorLayer = new ol.layer.Vector({
            source: vectorSource
        });
        vectorLayer.name = datas.name;
        vectorLayer.setVisible(false);
        map.addLayer(vectorLayer);
    }

    function cometo(id, name) {

        window.parent.open_window({
            "title": name,
            "url": pageConfig.url + "/gb_ephomepage/changzhan/changzhan.html?tag=displays/冀北/场站/场站.json&stationId=" + id
        });
        

    }

    //获取各场站运行小时数和损失小时数
    function stationOperateAnLossHours(stationId, startTime, endTime) {
        let urlOAL = attributeConfig.url + "/epplatform/areaStateTrack/areaStationOperateAnLossHours?"

        if (stationId) {
            urlOAL = urlOAL + "stationId=" + stationId + "&";
        }
        if (startTime) {
            urlOAL = urlOAL + "startTime=" + startTime + "&";
        }
        if (endTime) {
            urlOAL = urlOAL + "endTime=" + endTime + "&";
        }
        $.ajax({
            url: urlOAL,
            type: "GET",
            contentType: "application/json",
            dataType: "json",

            data: JSON.stringify(),
            success: function (result) {
                if (result.data) {
                    let runtime = 0;
                    let losstime = 0;
                    if (result.data[0]) {
                        if (result.data[0].runtime || result.data[0].losstime) {
                            losstime = result.data[0].losstime;
                            runtime = result.data[0].runtime;
                        }
                        ;
                    }
                    let pieData = [];
                    pieData.push(Object.assign({}, {value: losstime, name: "损失小时数"}));
                    pieData.push(Object.assign({}, {value: runtime, name: "运行小时数"}));
                    graphView_global.each(function (data) {
                        data._dataModel.getDataByTag('电场悬浮').a('data', pieData);
                    });
                }
            }
        });
    }
</script>
</head>

<body onload="init()">
<div id="mapDiv"></div>
</body>

</html>
